<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">   
    <title>注册-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link href="__STATIC__/css/reset.css" rel="stylesheet" />
    <link href="__STATIC__/css/reg3.css" rel="stylesheet" />
    <link rel='stylesheet' type='text/css' href='__STATIC__/css/common2.css'>    
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/common.min.css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.10.2.min.js"></script>
	<script src="__PUBLIC__/js/layer/layer.js"></script><!--弹窗js 参考文档 http://layer.layui.com/-->    
    <script src="__PUBLIC__/js/global.js"></script>
</head>
<body>
    <div class="regcon">
        <a class="m-fnlogoa fn-fl" href=""><img src="{$tpshop_config['shop_info_store_logo']}"/></a><span class="m-fntit">欢迎注册</span>
        <div class="ui_tab">
            <ul class="ui_tab_nav regnav">
                <li class="uli <if condition="$_GET['t'] eq ''">active</if> "><a href="{:U('Home/User/reg')}" >手机注册</a></li>
                <li class="uli <if condition="$_GET['t'] eq 'email'">active</if> "><a href="{:U('Home/User/reg/t/email')}">邮箱注册</a></li>
                <li class="no fn-fr loginbtn">我已注册，马上<a href="{:U('Home/User/login')}">登录></a></li>
            </ul>
            
<if condition="$_GET['t'] eq ''">    
		<form id="reg_form2" onsubmit=" return check_submit(this)" method="post" action="">            
            <div class="ui_tab_content">
                <div class="m-fnbox ui_panel" style="display: block;">
                    <div class="fnlogin clearfix">
                    
                        <div class="line">
                            <label class="linel"><span class="dt">手机号码：</span></label>
                            <div class="liner">
                                <input type="text" class="inp fmobile J_cellphone" placeholder="请输入手机号码"  name="username" id="username" required=""/>
                                <p class="fn-fl errorbox v-txt" id="err_username">手机号码输入不正确</p>
                            </div>
                        </div>       
                   <if condition="$tpshop_config['sms_regis_sms_enable'] eq 1" >
                        <div class="line">
                            <label class="linel"><span class="dt">手机验证码：</span></label>
                            <div class="liner">
                                <input type="text" class="inp imgcode J_imgcode" placeholder="手机验证码" id="code" name="code" required=""/>                                
                                <button class="fn-fl icode" onclick="send_sms_reg_code()" type="button" id="count_down">发送</button>
                                <p class="fn-fl errorbox v-txt" id="err_code">验证码输入不正确</p>
                            </div>
                            <div id="show-voice" class="show-voice"></div>
                        </div>
                   </if>
                        <div class="line">
                            <label class="linel"><span class="dt">设置密码：</span></label>
                            <div class="liner">
                                <input type="password" class="inp fpass J_password" placeholder="6-16位大小写英文字母、数字或符号的组合" autocomplete="off" maxlength="16"  id="password" name="password" value="" required=""/>
                                <p class="fn-fl noticebox v-txt2" id="err_password">6-16位字符，建议由字母、数字和符号两种以上组合</p>                               
                            </div>
                        </div>
                        <div class="line">
                            <label class="linel"><span class="dt">确认密码：</span></label>
                            <div class="liner">
                                <input type="password" class="inp fsecpass J_password2" placeholder="请再次输入密码" autocomplete="off" maxlength="16" id="password2" name="password2" required="" value=""/>
                                <p class="fn-fl errorbox v-txt" id="err_password2">两次输入密码不一致</p>
                            </div>
                        </div>
						<div class="line">
                            <label class="linel"><span class="dt">图像验证码：</span></label>
                            <div class="liner">
                                <input type="text" class="inp imgcode J_imgcode" placeholder="图像验证码" id="verify_code2" name="verify_code" required=""/>
								<img width="100" height="35" src="/index.php/Home/User/verify/type/user_reg.html" id="reflsh_code2" class="po-ab to0">
                                <a><img onclick="verify('reflsh_code2')" src="__STATIC__/images/chg_image.png" class="ma-le-210"></a>
                                <p class="fn-fl errorbox v-txt" id="err_verify_code">请输入验证码</p>
                            </div>
                            <div id="show-voice" class="show-voice"></div>
                        </div>
                        <div class="line liney clearfix">
                            <label class="linel">&nbsp;</label>
                            <div class="liner">
                                <div class="clearfix checkcon">
                                    <p class="fn-fl checktxt"><input type="checkbox" class="iyes fn-fl J_protocal" checked />
                                    <span class="fn-fl">我已阅读并同意</span><a class="itxt fn-fl" href="" target="_blank">《TPshop网服务协议》</a>
                                    </p>
                                      <p class="fn-fl errorbox v-txt" id="protocalBox"></p>
                                </div>
                                <a class="regbtn J_btn_agree" href="javascript:void(0);" onClick="$('#reg_form2').submit();">同意协议并注册</a>
                                <p class="v-txt" id="err_check_code"><span class="fnred">请勾选</span>我已阅读并同意<a class="itxt" href="" target="_blank">《TPshop网服务协议》</a></p>
                        </div>
                    </div>
                    </div>
                    </div>
            </div>
            </form>
</if>
<if condition="$_GET['t'] eq 'email'">    
		<form id="reg_form2" onsubmit=" return check_submit(this)" method="post" action="">            
            <div class="ui_tab_content">
                <div class="m-fnbox ui_panel" style="display: block;">
                    <div class="fnlogin clearfix">
                    
                        <div class="line">
                            <label class="linel"><span class="dt">邮箱：</span></label>
                            <div class="liner">
                                <input type="text" class="inp J_cellphone" placeholder="请输入邮箱"  name="username" id="username" required=""/>
                                <p class="fn-fl errorbox v-txt" id="err_username">邮箱输入不正确</p>
                            </div>
                        </div>
                        <if condition="$regis_smtp_enable eq 1">
                            <div class="line">
                                <label class="linel"><span class="dt">邮箱验证码：</span></label>
                                <div class="liner">
                                    <input type="text" class="inp imgcode J_imgcode" placeholder="邮箱验证码" id="code" name="code" required=""/>
                                    <button class="fn-fl icode" onclick="send_smtp_reg_code()" type="button" id="count_down">发送</button>
                                    <p class="fn-fl errorbox v-txt" id="err_code">验证码输入不正确</p>
                                </div>
                                <div id="show-voice" class="show-voice"></div>
                            </div>
                        </if>
                        <div class="line">
                            <label class="linel"><span class="dt">设置密码：</span></label>
                            <div class="liner">
                                <input type="password" class="inp fpass J_password" placeholder="6-16位大小写英文字母、数字或符号的组合" autocomplete="off" maxlength="16"  id="password" name="password" value="" required=""/>
                                <p class="fn-fl noticebox v-txt2" id="err_password">6-16位字符，建议由字母、数字和符号两种以上组合</p>                               
                            </div>
                        </div>
                        <div class="line">
                            <label class="linel"><span class="dt">确认密码：</span></label>
                            <div class="liner">
                                <input type="password" class="inp fsecpass J_password2" placeholder="请再次输入密码" autocomplete="off" maxlength="16" id="password2" name="password2" required="" value=""/>
                                <p class="fn-fl errorbox v-txt" id="err_password2">两次输入密码不一致</p>
                            </div>
                        </div>
						<div class="line">
                            <label class="linel"><span class="dt">图像验证码：</span></label>
                            <div class="liner">
                                <input type="text" class="inp imgcode J_imgcode" placeholder="图像验证码" id="verify_code2" name="verify_code" required=""/>
								<img width="100" height="35" src="/index.php/Home/User/verify/type/user_reg.html" id="reflsh_code2" class="po-ab to0">
                                <a><img onclick="verify('reflsh_code2')" src="__STATIC__/images/chg_image.png" class="ma-le-210"></a>
                                <p class="fn-fl errorbox v-txt" id="err_verify_code">请输入验证码</p>
                            </div>
                            <div id="show-voice" class="show-voice"></div>
                        </div>
                        <div class="line liney clearfix">
                            <label class="linel">&nbsp;</label>
                            <div class="liner">
                                <div class="clearfix checkcon">
                                    <p class="fn-fl checktxt"><input type="checkbox" class="iyes fn-fl J_protocal" checked />
                                    <span class="fn-fl">我已阅读并同意</span><a class="itxt fn-fl" href="" target="_blank">《TPshop网服务协议》</a>
                                    </p>
                                      <p class="fn-fl errorbox v-txt" id="protocalBox"></p>
                                </div>
                                <a class="regbtn J_btn_agree" href="javascript:void(0);" onClick="$('#reg_form2').submit();">同意协议并注册</a>
                                <p class="v-txt"><span class="fnred">请勾选</span>我已阅读并同意<a class="itxt" href="" target="_blank">《TPshop网服务协议》</a></p>
                        </div>
                    </div>
                    </div>
                    </div>
            </div>
            </form>
</if>
            
        </div>
    </div>    
</div>    
 <include file="Public/footer" />
<script>

    $(document).ready(function(){
		 $('input').click(function(){
		      $(this).siblings('p').hide();
		 });
	  	
	});
 
	// 普通 图形验证码 
    function verify(id){
        $('#'+id).attr('src','/index.php?m=Home&c=User&a=verify&type=user_reg&r='+Math.random());
    }
    function check_submit(){
        var username = $('input[name="username"]').val();
        var password = $('#password').val();
        var password2 = $('input[name="password2"]').val();
        var verify_code = $('input[name="verify_code"]').val();		
        var agree = $('input[type="checkbox"]:checked').val();
        var error = '';
		
		$("p[id^='err_']").each(function(){
			$(this).hide();
		});			
		
	   (username == '') && $('#err_username').show();
	   ($.trim($('#code').val()) == '') && $('#err_code').show();
	   (password == '') && $('#err_password').show();
	   (password2 != password) && $('#err_password2').show();
	   (verify_code == '') && $('#err_verify_code').show();
        (agree != 'on') && $('#err_check_code').show();
		if($('#username').hasClass('fmobile')){
			if(!checkMobile(username)){
				$('#err_username').show();
			}
		}else{
			if(!checkEmail(username)){
				$('#err_username').show();
			}
		}
	   if($("p[id^='err_']:visible").length > 0 ) 
		  return false;

    }
	// 电子邮件注册  和 手机号码注册 切换
    function reg_tab(id,id2){
        $('#'+id).addClass('ema-tab');
        $('#'+id2).removeClass('ema-tab');
        $('#'+id+'_div').show();
        $('#'+id2+'_div').hide();
    }
	// 发送手机短信
    function send_sms_reg_code(){
        var mobile = $('input[name="username"]').val();
        if(!checkMobile(mobile)){
            layer.alert('请输入正确的手机号码', {icon: 2});//alert('请输入正确的手机号码');
            return;
        }
        var url = "/index.php?m=Home&c=User&a=send_sms_reg_code&mobile="+mobile;
        $.get(url,function(data){
            obj = $.parseJSON(data);
            if(obj.status == 1)
			{
				$('#count_down').attr("disabled","disabled");
				intAs = {$sms_time_out}; // 手机短信超时时间
                jsInnerTimeout('count_down',intAs);
			}

            layer.alert(obj.msg, {icon: 1});// alert(obj.msg);
        })
    }

    // 发送邮箱
    function send_smtp_reg_code(){
        var email = $('input[name="username"]').val();
        if(!checkEmail(email)){
            layer.alert('请输入正确的邮箱', {icon: 2});//alert('请输入正确的手机号码');
            return;
        }
        $.ajax({
            type : "POST",
            url:"{:U('Home/User/send_validate_code')}",
            data : {type:'email',send:email},// 你的formid
            dataType: "json",
            success: function(data){
                if(data.status){
                    $('#count_down').attr("disabled","disabled");
                    intAs = {$sms_time_out}; // 发送邮箱超时时间
                    jsInnerTimeout('count_down',intAs);
                }
                layer.alert(data.msg, {icon: 1});// alert(obj.msg);
            }
        });
    }

    $('#count_down').removeAttr("disabled");
    //倒计时函数
    function jsInnerTimeout(id,intAs)
    {
        var codeObj=$("#"+id);
        //var intAs = parseInt(codeObj.attr("IntervalTime"));

        intAs--;
        if(intAs<=-1)
        {
            codeObj.removeAttr("disabled");
//            codeObj.attr("IntervalTime",60);
            codeObj.text("发送");
            return true;
        }

        codeObj.text(intAs+'秒');
//        codeObj.attr("IntervalTime",intAs);

        setTimeout("jsInnerTimeout('"+id+"',"+intAs+")",1000);
    };
    
    
    function checkMobile(tel) {
        var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
        if (reg.test(tel)) {
            return true;
        }else{
            return false;
        };
    }
    
    function checkEmail(str){
        var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if(reg.test(str)){
            return true;
        }else{
            return false;
        }
    }
</script>
</body> 
</html>
